
public class RockPaperScissors {
	
	public RockPaperScissors()
	{
		
	}

	public Result play(RPSEnum p1, RPSEnum p2)
	{
		Result r =Result.LOST;
		
		switch(p1)
		{
			case PAPER:
				switch(p2)
				{
					case PAPER:
						r=Result.TIE;
						break;
						
					case ROCK:
						r=Result.WIN;
						break;
						
					case SCISSORS:
							r=Result.LOST;
							break;
				}
				
			case ROCK:
				switch(p2)
				{
					case PAPER:
						r=Result.LOST;
						break;
						
					case ROCK:
						r=Result.TIE;
						break;
						
					case SCISSORS:
							r=Result.WIN;
							break;
				}
				
			case SCISSORS:
				switch(p2)
				{
					case PAPER:
						r=Result.WIN;
						break;
						
					case ROCK:
						r=Result.LOST;
						break;
						
					case SCISSORS:
							r=Result.TIE;
							break;
				}
		}
		return r;
	}

	Result player(Player p1, Player p2)
	{
		for(int i=0; i<p1.size(); i++)
		{
			if(play(p1.getNextMove(i), p2.getNextMove(i)) == Result.TIE)
			{
				int y =p1.getScore() +1;
				System.out.print("testeuu"+p1.getScore()+"  ");
				p1.setScore(y);
				y =p2.getScore()+1;
				p2.setScore(y);
			}
			else if(play(p1.getNextMove(i), p2.getNextMove(i)) == Result.WIN)
			{
				int y =p1.getScore()+1;
				p1.setScore(y);
			}
			else
			{
				int y =p2.getScore()+1;
				p2.setScore(y);
			}
		}
		System.out.println(p2.getName()+"  ");
		System.out.print(p2.getScore()+"  ");
		System.out.println(p1.getName()+"  ");
		System.out.print(p1.getScore()+"  ");
		if(p1.getScore()==p2.getScore()) return Result.TIE;
		else if(p1.getScore()>p2.getScore()) return Result.WIN;
		else return Result.LOST;
	}
}
